<script setup>
//在vue3 CompositionAPI中
// 1.获取路由对象 router useRouter
//   const router = useRouter()
// 2.获取路由参数 route useRoute
//  const route = useRoute()
import { useRoute, useRouter } from 'vue-router'
const router = useRouter()
const route = useRoute()
const getHome = () => {
  console.log('router', router)
  console.log('route', route)
  router.push('/home')
}
const getList = () => {
  router.push('/list')
}

// 导出pinia里面的数据方法
// import { useUserStore } from '@/stores/modules/user.js'
// import { useCounterStore } from '@/stores/modules/counter.js'
import { useUserStore, useCounterStore } from '@/stores'
// 登录退出
const useStore = useUserStore()
// countStre计数
const useCounter = useCounterStore()
</script>
<template>
  <div>我是App</div>
  <test-demo></test-demo>
  <!-- <button @click="$router.push('/home')">首页</button> -->
  <el-button type="primary" @click="getHome">首页</el-button>
  <el-button type="success" @click="getList">列表</el-button>
  <p>{{ useStore.token }}</p>
  <el-button type="" @click="useStore.setToken('Bearer sjsjsjjssjjssjjssj')">登录</el-button>
  <el-button type="" @click="useStore.removeToken">退出</el-button>
  <hr />
  {{ useCounter.count }}
  <el-button @click="useCounter.addCount">加法</el-button>
  <RouterView />
</template>

<style scoped></style>
